package com.aaa.commonmethods;

/**
 * @author C-Q
 * @version 1.1.0
 * @Description:
 *  public static void sleep(long millis)
 *  当前线程主动休眠millis毫秒。
 * @date 2022/11/1
 */
public class SleepDemo extends Thread{

    @Override
    public void run() {
        super.run();
        for (int i = 0; i < 20; i++) {
            try {
                Thread.sleep(1000);
                //休眠时间过后会继续执行
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName()+"~~~~~"+i);
        }
    }
}
class Test {
    public static void main(String[] args) {
        SleepDemo sleepDemo = new SleepDemo();
        sleepDemo.start();
    }
}